package com.sky.controller.admin;

import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.common.DishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author:JinFeng
 * @Date: 2025/09/24 17:04
 * @Description:
 */
@RestController
@Slf4j
@RequestMapping("/admin/dish")
@Api(tags = "后台菜品相关接口")
public class DishController {
    @Autowired
    private DishService dishService;

    @ApiOperation("新增菜品及口味")
    @PostMapping
    public Result<String> add(@RequestBody DishDTO dishDTO){
        log.info("新增菜品：{}",dishDTO);
        return dishService.addWithFlavors(dishDTO);
    }
    /**
     * 菜品分页查询
     *
     * @param dishPageQueryDTO
     * @return
     */
    @GetMapping("/page")
    @ApiOperation("菜品分页查询")
    public Result<PageResult> page(DishPageQueryDTO dishPageQueryDTO) {
        log.info("菜品分页查询:{}", dishPageQueryDTO);
        return dishService.pageQuery(dishPageQueryDTO);//后绪步骤定义

    }
}
